﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebService.Connect;
using System.Data.SqlClient;
using Model;
using System.Data;

namespace WebService.Datalayer
{
    public class DBMenus
    {
        Database db = new Database();
        SqlParameter[] listParameter;

        /// <summary>
        /// SelecMenusAll
        /// </summary>
        /// <returns></returns>
        public DataSet SelectMenusAll()
        {
            return db.GetDataset("sp_SelectMenusAll");
        }

        /// <summary>
        /// SelectMenusByAndMenuID
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public DataSet SelectMenusByAndMenuID(Menus obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@MenuID", obj.MenuID),
            };
            return db.GetDataSetWithParameter("sp_SelectMenusByAndMenuID", listParameter);
        }

        /// <summary>
        /// SelectMenusByAndMenuTypeID
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public DataSet SelectMenusByAndMenuTypeID(Menus obj)
        {
             listParameter = new SqlParameter[]
            {
                new SqlParameter("@MenuTypeID", obj.MenuTypeID),
            };
            return db.GetDataSetWithParameter("sp_SelectMenusByAndMenuTypeID", listParameter);
        }

        /// <summary>
        /// SelectMenusByAndUnitID
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public DataSet SelectMenusByAndUnitID(Menus obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@UnitID", obj.UnitID),
            };
            return db.GetDataSetWithParameter("sp_SelectMenusByAndUnitID", listParameter);
       
        }

        /// <summary>
        /// DeleteMenu
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int DeleteMenu(Menus obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@MenuID", obj.MenuID),
            };
            return db.ExcuteQueryWithParamater("sp_DeleteMenu", listParameter);
        }

        /// <summary>
        /// InsertMenus
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int InsertMenu(Menus obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@MenuID", obj.MenuID),
                new SqlParameter("@MenuTypeID", obj.MenuTypeID),
                new SqlParameter("@MenuName", obj.MenuName),
                new SqlParameter("@Price", obj.Price),
                new SqlParameter("@UnitID", obj.UnitID),
                new SqlParameter("@IsDeleted", obj.IsDeleted),
                new SqlParameter("@Total", obj.Total),
                new SqlParameter("@Picture", obj.Picture),
            };
            return db.ExcuteQueryWithParamater("sp_InsertMenu", listParameter);
        }

        /// <summary>
        /// UpdateMenu
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int UpdateMenu(Menus obj)
        {
             listParameter = new SqlParameter[]
            {
                new SqlParameter("@MenuTypeID", obj.MenuTypeID),
                new SqlParameter("@MenuName", obj.MenuName),
                new SqlParameter("@Price", obj.Price),
                new SqlParameter("@UnitID", obj.UnitID),
                new SqlParameter("@IsDeleted", obj.IsDeleted),
                new SqlParameter("@MenuID", obj.MenuID),
                new SqlParameter("@Total", obj.Total),
                new SqlParameter("@Picture", obj.Picture),
            };
             return db.ExcuteQueryWithParamater("sp_UpdateMenu", listParameter);
        }
    }
}